package jdbctest;

import java.sql.*;

/**
 * Created by Administrator on 2017/9/11.
 */
public class InsertTest {
    public static void main(String[] args) throws ClassNotFoundException, SQLException {
//        //加载驱动
//        Class.forName("com.mysql.jdbc.Driver");
//        //连接数据库
//        Connection conn= DriverManager.getConnection("jdbc:mysql://localhost:3307/my_table","root","123456");
        Connection conn=ConnectionUtils.getConnection();
        //获得statement
        Statement statement=conn.createStatement();
        //执行sql(表中插入一条记录)
        String sql="insert into user (username,password)values('xiaowang','123456')";
        statement.executeUpdate(sql);
        //关闭资源
        statement.close();
        conn.close();
    }
}
